﻿@{
    Layout = "~/_SiteLayout.cshtml";

    Business.Platform.WorkFlowTask bworkFlowTask = new Business.Platform.WorkFlowTask();
    Business.Platform.WorkFlow bworkFlow = new Business.Platform.WorkFlow();
    
    string title="";
    string flowid="";
    string sender="";
    string date1="";
    string date2="";

    if (IsPost)
    {
        title = Request.Form["Title"];
        flowid = Request.Form["FlowID"];
        sender = Request.Form["SenderID"];
        date1 = Request.Form["Date1"];
        date2 = Request.Form["Date2"];
    }
    else
    {
        title = Request.QueryString["title"];
        flowid = Request.QueryString["flowid"];
        sender = Request.QueryString["sender"];
        date1 = Request.QueryString["date1"];
        date2 = Request.QueryString["date2"];
    }

    string query = string.Format("&appid={0}&tabid={1}&title={2}&flowid={3}&sender={4}&date1={5}&date2={6}",
        Request.QueryString["appid"], Request.QueryString["tabid"], title.UrlEncode(), flowid, sender, date1, date2);
    string pager;
    
    var taskList = bworkFlowTask.GetTasks(Business.Platform.Users.CurrentUserID,
       out pager, query, title, flowid, sender, date1, date2);

    string flowOptions = bworkFlow.GetOptions(flowid);

}
<form action="" method="post" >
<div class="querybar">
    <table cellpadding="0" cellspacing="0" border="0" width="100%">
        <tr>
            <td>
                名称：<input type="text" class="mytext" id="Title" name="Title" value="@title" />
                所属流程：<select class="myselect" id="FlowID" name="FlowID"><option value="">==全部==</option>@Html.Raw(flowOptions)</select>
                发送人：<input type="text" class="mymember" id="SenderID" unit="0" dept="0" station="0" user="1" group="0" more="0" name="SenderID" value="@sender"  />
                接收时间：<input type="text" class="mycalendar" style="width:90px;" value="@date1" name="Date1" /> 至 <input type="text" value="@date2" style="width:90px;" class="mycalendar" name="Date2" />
                <input type="submit" name="Search" value="查询" class="mybutton" />
            </td>
        </tr>
    </table>
</div>

<table cellpadding="0" cellspacing="1" border="0" class="listtable">
    <thead>
        <tr>
            <th>任务标题</th>
            <th>流程</th>
            <th>步骤</th>
            <th>发送人</th>
            <th>接收时间</th>
            <th>状态</th>
            <th>备注</th>
            <th></th>
        </tr>
    </thead>
    <tbody>
    @foreach (var task in taskList)
    {
        string flowName;
        string stepName = bworkFlow.GetStepName(task.StepID, task.FlowID, out flowName);
        string query1 = string.Format("flowid={0}&stepid={1}&instanceid={2}&taskid={3}&groupid={4}&appid={5}",
            task.FlowID, task.StepID, task.InstanceID, task.ID, task.GroupID, Request.QueryString["appid"]
            );
        <tr>
            <td><a href="javascript:void(0);" onclick="openTask('/Platform/WorkFlow/Run/Default?@Html.Raw(query1)','@task.Title','@task.ID');return false;" class="blue">@task.Title</a></td>
            <td>@flowName</td>
            <td>@stepName</td>
            <td>@task.SenderName</td>
            <td>@task.ReceiveTime</td>
            <td>@bworkFlowTask.GetStatusTitle(task.Status)</td>
            <td>@task.Note</td>
            <td>
                <a class="viewlink" href="javascript:void(0);" onclick="detail('@task.FlowID','@task.GroupID');">查看</a>

            </td>
        </tr>
    }
    </tbody>
</table>
<div class="buttondiv">@Html.Raw(pager)</div>
</form>
<script type="text/javascript">
    function openTask(url, title, id)
    {
        top.openApp(url, 0, title, "tab_" + id, 0, 0, false);
    }
    function detail(flowid, groupid)
    {
        top.mainDialog.open({ url: '/Platform/WorkFlow/Tasks/Detail?flowid1=' + flowid + "&groupid=" + groupid + '@Html.Raw(query)',
            width: 980, height: 530, title: "查看流程处理过程"
        });
    }
</script>